//
//  DSNavigationController.m
//  ZhiJiaLianMeng
//
//  Created by AntSailNet on 2018/3/1.
//  Copyright © 2018年 Befiv. All rights reserved.
//

#import "DSNavigationController.h"
#import "PrefixHeader.pch"

@interface DSNavigationController ()

@end

@implementation DSNavigationController


/**
 首次调用该类是加载
 */
+ (void)initialize
{
    UINavigationBar *navBar = [UINavigationBar appearance];
  //  [navBar setBackgroundImage:[UIImage imageNamed:@"nav_org"] forBarMetrics:UIBarMetricsDefault];
    [navBar setShadowImage:[UIImage new]];
    NSMutableDictionary *mutDic = [NSMutableDictionary dictionary];
    mutDic[NSForegroundColorAttributeName] = [UIColor whiteColor];
    mutDic[NSFontAttributeName] = [UIFont systemFontOfSize:17*hl];
    [navBar setTitleTextAttributes:mutDic];
   
}

/**
 重写push方法
 */
- (void)pushViewController:(UIViewController *)viewController animated:(BOOL)animated
{
    if(self.viewControllers.count > 0)
    {
        viewController.hidesBottomBarWhenPushed = YES;
        _backBtn = [UIButton buttonWithType:UIButtonTypeCustom];
        [_backBtn setImage:[UIImage imageNamed:@"nav_back"] forState:UIControlStateNormal];
        [_backBtn setImage:[UIImage imageNamed:@"nav_back"] forState:UIControlStateHighlighted];
        _backBtn.frame = CGRectMake(-10, 0, 33, 44);
        [_backBtn addTarget:self action:@selector(back) forControlEvents:UIControlEventTouchUpInside];
        viewController.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc] initWithCustomView:_backBtn];
    }
    
    //跳转
    [super pushViewController:viewController animated:animated];
}

- (void)back
{
    
    [self popViewControllerAnimated:YES];
    
}
- (CGSize)intrinsicContentSize {
    return UILayoutFittingExpandedSize;
}

 
//- (NSArray<UIViewController *> *)popToViewController:(UIViewController *)viewController animated:(BOOL)animated{
//    if ([viewController isKindOfClass:[MeViewController class]]) {
//        [viewController setHidesBottomBarWhenPushed:NO];
//    }
//    return [super popToViewController:viewController animated:NO];
//}
- (void)viewDidLoad {
    [super viewDidLoad];
}


- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}
/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
